<#import "/macro.ftl" as m>
<@m.page_header title='后台' />
<div id="page-content-wrapper">

<div id="page-title">

    <h3>
       	产品数据分析
    </h3>
</div>
<div id="page-content">
		<form id="form" action="/stat/productanalyse" method="get">
    		<div class="form-row">
    			<div class="form-input col-md-2">
    			<label for="from">
                    From:
                </label>
    				<#if startTime>
            		<input type="text"   name="startTime" data-trigger="focus" data-required="true" class="parsley-validated" value="${startTime}" onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})" style="clear:both;overflow:hidden;display:block">
          			<#else>
    				<input placeholder="起始时间" type="text"   name="startTime" data-trigger="focus" data-required="true" class="parsley-validated" value="" onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})" style="clear:both;overflow:hidden;display:block">
    				</#if>
    			</div>
    			<div class="form-input col-md-2">
    				<label for="from">
	                    To:
	                </label>	
    				<#if endTime>
		            <input type="text"   name="endTime" data-trigger="focus" data-required="true" class="parsley-validated" value="${endTime}" onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})" style="clear:both;overflow:hidden;display:block">
		            <#else>
		            <input placeholder="结束时间" type="text"   name="endTime" data-trigger="focus" data-required="true" class="parsley-validated" value="" onClick="WdatePicker({isShowWeek:true,dateFmt:'yyyy-MM-dd'})" style="clear:both;overflow:hidden;display:block">
		            </#if>
		         </div>
    			<div class="form-input col-md-2" style="margin-top:16px;">
		        	<a href="javascript:;" class="btn large primary-bg radius-all-4" id="search" title="Validate!">
			            <span class="button-content">
			                查询
			            </span>
	                </a>
		        </div>
		    		<div style="margin-top:15px;">
				        <a href="/stat/productexport/${startTime}&${endTime}" class="btn large primary-bg" title="">
				            <span class="button-content">导出Excel</span>
				        </a>
	   				</div>
    		</div>
    	</form>
    	
<table class="table" id="exp">
	    <thead>
	    <tr>
	    	<th>日期</th>
	        <th>产品</th>
	        <th>交易次数</th>
	        <th>成功交易次数</th>
	        <th>交易金额</th>
	        <th>成功交易用户数</th>
	        <th>交易用户数</th>
	        <th>人均ARUP</th>
	        <th>交易成功率</th>
	    </tr>
	    </thead>
	    <tbody>
	    <#list result?keys as resultKey>
	    
	    <#list productNameList as source>
	    <#if result[resultKey][source.name]["dealTimesAnalyse"]!=0>
	    <tr>
	    	<td>${resultKey}</td>
	        <td>${source.name}</td>
	        <td>${result[resultKey][source.name]["dealTimesAnalyse"]}</td>
	        <td class="center">${result[resultKey][source.name]["successTimesAnalyse"]}</td>
	        <td class="center">${result[resultKey][source.name]["dealSalesAnalyse"]}</td>
	        <td class="center">${result[resultKey][source.name]["successBuyersAnalyse"]}</td>
	        <td class="center">${result[resultKey][source.name]["dealBuyersAnalyse"]}</td>
	        <td class="center">${result[resultKey][source.name]["perARUP"]}</td>
	        <td class="center">${result[resultKey][source.name]["successrate"]}</td>
	    </tr>
	    </#if>
	    </#list>
	    </#list>
	    </tbody>
	    <tfoot>
	    <tr>
	    	<th>日期</th>
	        <th>产品</th>
	        <th>交易次数</th>
	        <th>成功交易次数</th>
	        <th>交易金额</th>
	        <th>成功交易用户数</th>
	        <th>交易用户数</th>
	        <th>人均ARUP</th>
	        <th>交易成功率</th>
	    </tr>
	    </tfoot>
	    </table>


</div>
</div>
<script type="text/javascript">

$(function(){
		$("#search").click(function(){
			$('#form').parsley('validate');
	    	$('#form').trigger('submit');
		});
	});

</script>